/**
 * PictureUpload.java
 * Wraps an uploaded image file in an image data access object.
 */
package com.example.myproject;

import java.io.File;

public class PictureUpload {
	
	public PictureUpload(){}
	
	/**
	 * Uploads an image file to the blobstore.
	 * @param src The source image file to be uploaded.
	 * @param master 
	 * @return true if successfully uploaded, false if not.
	 */
	public boolean upload(File src, UploadDTO master)
	{
		
		try {
			
			PictureUploadDTO picture = new PictureUploadDTO();
			PictureUploadDAO dao = new PictureUploadDAO();
			
			picture.setTitle(master.getTitle());
			picture.setCaption(master.getCaption());
			picture.setContentType(master.getContentType());
			picture.setPath(master.getPath());
			picture.setParentId(master.getId());
			dao.save(picture);
			return true;
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		
	}
	
}
